package com.liqw.auto.bean;

import com.liqw.Constant;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeansException;
import org.springframework.beans.PropertyValues;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessor;

import javax.annotation.PostConstruct;

@Slf4j
public class CustomBean implements InitializingBean, DisposableBean {
    public CustomBean() {
        System.out.println(Constant.getStepStr("CustomBean") + "CustomBean - 构造函数");
    }

    @PostConstruct
    public void test() {
        System.out.println(Constant.getStepStr("CustomBean.PostConstruct") + "CustomBean - PostConstruct");
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println(Constant.getStepStr("CustomBean.afterPropertiesSet") + "CustomBean - InitializingBean.afterPropertiesSet");
    }

    public void init() {
        System.out.println(Constant.getStepStr("CustomBean.init") + "CustomBean - initMethod");
    }

    @Override
    public void destroy() throws Exception {
        System.out.println(Constant.getStepStr("CustomBean.destroy") + "CustomBean - DisposableBean.destroy");
    }
}